Skip to content

Fix compiler warning: specified bound 4096 equals destination size - #214

Merged
twogood merged 1 commit into
twogood:mainfrom
kratz00:oob
Feb 17, 2026
Merged

twogood merged 1 commit into
twogood:mainfrom
kratz00:oob

Conversation

@kratz00

@kratz00 kratz00 commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Fixes the following compiler warning:

[6/13] Building C object lib/CMakeFiles/libunshield.dir/helper.c.o
/home/runner/work/unshield/unshield/lib/helper.c: In function ‘unshield_get_base_directory_name’:
/home/runner/work/unshield/unshield/lib/helper.c:50:9: warning: ‘__builtin_strncpy’ specified bound 4096 equals destination size [-Wstringop-truncation]
   50 |         strncpy(dirname, unshield->filename_pattern, path_max);
      |         ^

I guess it does not make sense to continue, if dirname is too small.
So I refactored the code and used the new UNSHIELD_ASSERT 😄

@kratz00
kratz00 marked this pull request as ready for review February 13, 2026 21:50

@twogood twogood left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put the assert before the strncpy as well?

@kratz00

kratz00 commented Feb 16, 2026

Copy link
Copy Markdown
Contributor Author

Not sure what you mean exactly. Just switch line 50 and 51, to fail early?

@twogood

twogood commented Feb 16, 2026

Copy link
Copy Markdown
Owner

Not sure what you mean exactly. Just switch line 50 and 51, to fail early?

Yes, sorry for being unclear

Signed-off-by: Steffen Pankratz <kratz00@gmx.de>
@kratz00

kratz00 commented Feb 16, 2026

Copy link
Copy Markdown
Contributor Author

All good. Done.

@twogood
twogood merged commit 00da872 into twogood:main Feb 17, 2026
6 checks passed
@kratz00
kratz00 deleted the oob branch February 17, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants